using dnAnalytics.Statistics.Distributions;
using NUnit.Framework;

namespace dnAnalytics.Tests.Statistics.Distributions
{
    [TestFixture]
    public class InverseGammaTests
    {
        private const double mAcceptableError = 1e-12;

        [Test]
        public void InverseGamma()
        {
            InverseGamma igamma = new InverseGamma(10.0, 3.0);

            Assert.AreEqual(3.0 / 9.0, igamma.Mean, mAcceptableError);
            Assert.AreEqual(System.Math.Sqrt(3.0 * 3.0 / (9.0 * 9.0 * 8.0)), igamma.StdDev, mAcceptableError);
            Assert.AreEqual(3.0 * 3.0 / (9.0 * 9.0 * 8.0), igamma.Variance, mAcceptableError);
            Assert.AreEqual(3.0 / 11.0, igamma.Mode, mAcceptableError);
        }

        [Test]
        public void GetSetRNG()
        {
            InverseGamma igamma = new InverseGamma(10.0, 3.0);

            // Try getting the random number generator.
            System.Random rnd = igamma.RandomNumberGenerator;
            // Try setting the random number generator.
            igamma.RandomNumberGenerator = new System.Random();
        }
    }
}